<template lang="pug">
	.weui-flex
		.weui-flex__item
			.placeholder.box-container
				ul
					.href(v-for='(item, index) in typeProduct' :to='item.href' :key='index' @click='focusProduct(item.id)')
						img(:src="item.imgUrl")
						p {{item.info.name}}&nbsp;{{item.info.weight}}
						.price ￥{{item.info.price}}
</template>
<script>
import {mapState} from 'vuex'
export default {
	computed: {
		...mapState([
			'typeProduct'
		])
	},
	methods: {
		focusProduct(id){
			this.$router.push({path: '/deal', query: {id: id}})
		}
	},
	beforeCreate () {
		let path = this.$route.path.replace('/select/','')
		console.log(path)
		if (path === '/') {
			this.$store.dispatch('getnewProduct')	
		} else {
			path = path.replace('/','')
			console.log(path)
			this.$store.dispatch('getTypeProduct',path)
		}

	}

}
</script>
<style scoped lang="sass">
.box-container
	> ul
		width: 100%
		.href
			margin: 0% 0% 1.4% 2.6%
			width: 46%
			height: 180px
			display: inline
			background-color: #F5F6F5
			float: left
			color: #333
			border-radius: 6px
			text-align: center
			font-size: 13px
			img
				height: 65%
				width: 80%
			p
				font-weight: 520
			.price
				font-weight: 400

</style>